import 'package:flutter/material.dart';
import 'package:hbtrans_flutter/beans/classdetail_bean.dart';
import 'package:hbtrans_flutter/utils/fluro.dart';

class Page1 extends StatelessWidget {
  final content;

  const Page1({Key key, this.content}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    ClassdetailBean bean;
    var map = FluroConvertUtils.string2map(
        FluroConvertUtils.fluroCnParamsDecode(content));
    bean = ClassdetailBean.fromJson(map);

    return Container(
      color: const Color(0xfffbfbfb),
      child: Column(
        children: <Widget>[
          Container(
            padding: EdgeInsets.symmetric(horizontal: 30, vertical: 20),
            color: const Color(0xff23AFDC),
            child: Row(
              children: <Widget>[
                Image.network(
                  bean.photourl,
                  height: 60,
                  width: 60,
                  fit: BoxFit.fitHeight,
                ),
                SizedBox(
                  width: 10,
                ),
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(bean.name,
                        style: TextStyle(fontSize: 18, color: Colors.white)),
                    Text('驾照类型: ${bean.traintype}',
                        style: TextStyle(fontSize: 12, color: Colors.white)),
                  ],
                ),
              ],
            ),
          ),
          Stack(
            children: <Widget>[
              Container(
                height: 54,
                color: const Color(0xff23AFDC),
              ),
              Card(
                color: Colors.white,
                shape: const RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(Radius.circular(18))),
                elevation: 20,
                margin: EdgeInsets.symmetric(horizontal: 15),
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 60),
                  child: Column(
                    children: <Widget>[
                      SizedBox(
                        height: 36,
                      ),
                      Item(
                        image: 'images/ic_card_id.png',
                        text: bean.idcard,
                      ),
                      Item(
                        image: 'images/ic_car.png',
                        text: bean.address,
                      ),
                      Item(
                        image: 'images/ic_time.png',
                        text: bean.applydate,
                      ),
                      Item(
                        image: 'images/icon_phone.png',
                        text: bean.phone,
                      ),
                      Item(
                        image: 'images/ic_server.png',
                        text: bean.schName,
                      ),
                      SizedBox(
                        height: 25,
                      ),
                    ],
                  ),
                ),
              ),
            ],
          )
        ],
      ),
    );
  }
}

class Item extends StatelessWidget {
  final image;
  final text;

  const Item({Key key, this.image, this.text}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        SizedBox(height: 11),
        Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Image.asset(
              image,
              height: 25,
              width: 25,
            ),
            SizedBox(width: 10),
            SizedBox(
              width: 190,
              child: Text(text,
                  softWrap: true,
                  style:
                      TextStyle(fontSize: 16, color: const Color(0xff333333))),
            )
          ],
        ),
        SizedBox(height: 11),
        Container(
          height: 2,
          width: 285,
          color: const Color(0xffb7e1f4),
        ),
      ],
    );
  }
}
